<?php
/**
 * 名称：ComplaintsAction
 * 描述：投诉管理
 * 作者：jepin 时间：2014-07-22
 * 版本号：V1.0.0
 * ========================历史版本=================================
 * 序号	 版本号 	日期			姓名	 	描述
 * 1 	V1.0.0 	2014-07-22 	jepin  	投诉管理
 * ========================历史版本=================================
 * 说明：请在有更改程序的时候修改以上注释
 */
class ComplaintsAction extends CommonAction {	
	/**
	 *投诉列表
	 */
	public function complaints(){
		import("ORG.Util.Page"); // 导入分页类
		if($_GET['uname'] != null && $_GET['uname'] != "" ){
			$map['uname'] = array("like","%".$_GET['uname']."%");
			$this->assign("uname",$_GET['uname']);
			$this->assign("search","yes");
		}
		$count = model('Complaints') -> where($map)->count();
		$page = new Page($count,20);
		$sql ='SELECT c.messageid,c.uid,c.uname,w.content,c.ctime from '.C('DB_PREFIX').'user_complaints c,'.C('DB_PREFIX').'weibo w where ';
		$sql.='c.messageid=w.weibo_id and c.uname like "%'.$_GET['uname'].'%" order by c.uid limit '.$page->firstRow.','. $page->listRows;
		$complaints_list = M()->query($sql);
		
		//$complaints_list = model('Complaints')  -> where($map) -> order('id') -> limit($page->firstRow . ',' . $page->listRows)->select();
		$show = $page->show(); // 分页显示输出
		$this->assign('page', $show); // 赋值分页输出
		$this->assign('complaints_list', $complaints_list);
		$this->display();
	}
	 
	/**
	 * 删除投诉
	 */
	public function doDelComplaints(){
		if($_POST['ids'] == null || $_POST['ids'] == "" ){
			echo 0;
			exit();
		}
		//页面传过来的为复合主键 方式为  uid;messageid,uid2;messageid2  的形式
		$ids = $_POST['ids'];
		$groubids =explode(",",$ids);
		foreach($groubids as $groub){
			$idtemp =explode(";",$groub);
			$res = model('Complaints') -> where("`uid` = ".$idtemp[0]." and messageid = ".$idtemp[1]) -> delete();
		}
		echo $res ? 1 : 0;
	}
   
}
?>
